package com.itheima;

import java.util.Arrays;

public class topic283 {

    public static void topic283(int[] nums) {

        //指向0的位置
        int a = 0;
        //指向非零的位置
        int b = 0;

        for(int i = 0; i < nums.length; i++) {
            if (nums[i] == 0) {
                a = i;
                b = i + 1;
                break;
            }
        }

        while(b <= nums.length - 1) {
            if (nums[b] != 0) {
                nums[a] = nums[b];
                a++;
            }
            b++;
        }
        while(a <= nums.length - 1) {
            nums[a] = 0;
            a++;
        }

        System.out.println(Arrays.toString(nums));

    }

    public static void main(String[] args) {

        topic283.topic283(new int[]{0,1,0,3,12});
    }
}
